'''
添加产品界面
'''

from selenium.webdriver.common.by import By
from page.base_page import BasePage

class AddProductPage(BasePage):
    url="/crm/index.php?m=product&a=add"

    #定位器
    cp_name_locator = (By.NAME, "name")
    time_locator = (By.NAME, "development_time")
    link_locator = (By.NAME, "link")
    development_team_locator = (By.NAME, "development_team")
    cost_price_locator = (By.NAME, "cost_price")
    suggested_price_locator = (By.NAME, "suggested_price")
    select_file_locator = (By.NAME, "main_pic[]")
    description_locator = (By.CSS_SELECTOR, "#description")
    save_locator = (By.CSS_SELECTOR, "#form1 > table > tfoot > tr > td > input:nth-child(1)")

    def input_cp_name(self,cp_name):
        '''输入产品名称'''
        self.driver.find_element(*self.cp_name_locator).send_keys(cp_name)
    def input_time(self,time):
        '''输入研发时间'''
        self.driver.find_element(*self.time_locator).send_keys(time)
    def click_link(self):
        '''点击链接输入框'''
        self.driver.find_element(*self.link_locator).click()
    def clear_link(self):
        '''清除链接输入框内容'''
        self.driver.find_element(*self.link_locator).clear()
    def input_link(self,link):
        '''输入链接'''
        self.driver.find_element(*self.link_locator).send_keys(link)
    def input_development_team(self,development_team):
        '''输入开发团队'''
        self.driver.find_element(*self.development_team_locator).send_keys(development_team)
    def input_cost_price(self,cost_price):
        '''输入成本价'''
        self.driver.find_element(*self.cost_price_locator).send_keys(cost_price)
    def input_suggested_price(self,suggested_price):
        '''输入建议售价'''
        self.driver.find_element(*self.suggested_price_locator).send_keys(suggested_price)
    def input_select_file(self,file):
        '''选择图片文件上传'''
        self.driver.find_element(*self.select_file_locator).send_keys(file)
    def input_description(self,description):
        '''输入描述'''
        self.driver.find_element(*self.description_locator).send_keys(description)
    def click_save(self):
        '''点击保存按钮'''
        self.driver.find_element(*self.save_locator).click()
